<?function getCurrentEvents() {
	global $eventString, $dbname, $db, $db_selected, $pre;	// First, let's remove any outdated events from the webiste.	$today = date('Y-m-d');	$sql = "UPDATE transEvents SET Active = 0			WHERE			DateStart < '$today' AND			DateEnd   < '$today'";	$result = mysql_db_query($dbname,$sql);
	$eventString = '';	$sql = "SELECT * from transCategories WHERE CatType = 'C' ORDER BY CatName";	$result = mysql_db_query($dbname,$sql);
	while ($value = mysql_fetch_assoc($result)) {		$catID   = $value[CID];		$catName = stripslashes($value[CatName]);
		$sql2 = "SELECT * from transEvents WHERE ECat = '$catID' ORDER BY DateStart DESC"; 		$result2 = mysql_db_query($dbname,$sql2);		$rows2 = mysql_num_rows($result2);
		if ($rows2>0) { $eventString .= '<h3>'.$catName.'</h3>'; }		$i=1;		while ($value2 = mysql_fetch_assoc($result2)) {			if (($i % 2) > 0) { $class = 'noRowClass'; }			else { $class = "altRow"; }			$eID       = $value2[EID];			$eTitle    = stripslashes($value2[EventTitle]);			$eLocation = stripslashes($value2[EventLocation]);			$eDesc     = stripslashes($value2[EventDesc]);			$eURL      = $value2[EventURL];			$eRegURL   = $value2[EventRegURL];			$dateTimeStart = convertDateTime($value2[DateStart]);			$dateTimeEnd   = convertDateTime($value2[DateEnd]);			$eTimes    = $value2[EventTimes];			$eReg      = $value2[Registration];			$active    = $value2[Active];
			$dateStart = $dateTimeStart[0];			$dateEnd   = $dateTimeEnd[0];
			$eventString .= '<div class="'.$class.'" id="row'.$eID.'" onMouseOver="rowHoverControls('.$eID.',\'on\');" onMouseOut="rowHoverControls('.$eID.',\'off\',\''.$class.'\')">';			$eventString .= '<div style="padding: 3px; text-align: center; vertical-align: top; width: 50px; float: left;">';				$eventString .= '<div style="display: none;" id="control'.$eID.'">';				$eventString .= '<a href="#" onClick="editEvent('.$eID.'); return false;"><img src="images/buttonEditBig.gif" id="editButton'.$eID.'" style="border: none;" alt="Edit" /></a>';				$eventString .= '&nbsp;<a href="#" onClick="confirmDelete(\''.$eID.'\',\'event\'); return false;"><img src="images/buttonDeleteBig.gif" style="border: none;" alt="Delete" /></a>';				$eventString .= '</div>';			$eventString .= '</div><div style="width: 85%; float: left; padding: 3px;">';
			$eventString .= '<h4>'.$eTitle.'</h4>';			$eventString .= '<p><b>Dates:</b> '.$dateStart;			if (!empty($dateEnd)) {				$eventString .= ' to '.$dateEnd;			}			$eventString .= '</p>';			if (!empty($eTimes)) {				$eventString .= '<p><b>Times:</b> '.$eTimes.'</p>';			}
			// Check for active			$eventString .= '<div id="activeDiv'.$eID.'" style="float: left; margin-left: 5px;">';			if ($active == 1) {				$eventString .= '<img src="images/iconCheckGreenOn.gif" onClick="swapActive('.$eID.'); return false;" style="cursor: pointer;" alt="Click to deactivate event" /> Active Event';			} else {				$eventString .= '<img src="images/iconCheckGreenOff.gif" onClick="swapActive('.$eID.'); return false;" style="cursor: pointer;" alt="Click to activate event" /> <span style="color: #ccc;">Not Active</span>';			}			$eventString .= '</div>';
			
			// Check for on home page
			$eventString .= '<div id="onHomeDiv'.$eID.'" style="float: left; margin-left: 5px;">';
			if ($active == 1) {
				$eventString .= '<img src="images/iconCheckGreenOn.gif" onClick="swapOnHome('.$eID.'); return false;" style="cursor: pointer;" alt="Click to remove from home page" /> On Home Page';
			} else {
				$eventString .= '<img src="images/iconCheckGreenOff.gif" onClick="swapOnHome('.$eID.'); return false;" style="cursor: pointer;" alt="Click to put on home page" /> <span style="color: #ccc;">On Home Page</span>';
			}
			$eventString .= '</div><div style="clear: left;"></div>';
			if (!empty($eLocation)) {				$eventString .= '<p class="sectionLocation">'.$eLocation.'</p>';			}			if (!empty($eURL)) {				$eventString .= '<p class="sectionWebsite"><a href="'.$eURL.'" target="_blank">Event website</a></p>';			}			if (!empty($eRegURL)) {				$eventString .= '<p class="sectionWebsite"><a href="'.$eRegURL.'" target="_blank">Event registration link</a></p>';			}						if (!empty($eDesc)) {				$eventString .= '<p>'.$eDesc.'</p>';			}			if ($regCount>0) {				$eventString .= '<div style="float: right;" class="regButton" onclick="showRegistered('.$eID.'); return false;" title="View registrations">'.$regCount.' Registered</div>';			}			$eventString .= '</div><div style="clear: left; height: 10px;"></div></div>';
			$i++;		}		$eventString .= '<div style="height: 20px;"></div>';	}	return $eventString;}
function getNewsCategories($display=null) {	global $catString, $dbname, $db, $db_selected, $pre;
	$catString = '';	// Get news and announcements	$sql = "SELECT * from ncdb_MainCat WHERE SiteArea = 'N' ORDER BY DisplayOrder";	$result = mysql_db_query($dbname,$sql);		while ($value = mysql_fetch_assoc($result)) {		$catID   = $value[CatID];		$catName = stripslashes($value[CatTitle]);			if ($display == 'select') {			$catString .= '<option value="'.$catID.'">'.$catName.'</option>';		}	}	return $catString;}
function saveEvent($phpString,$action=null) {	global $catString, $dbname, $db, $db_selected, $pre;	$userid = $_SESSION[UID];		// Parse phpString	$eArray = explode('|',$phpString);	
	$eID        = $eArray[0];	$eCat       = $eArray[1];	$eTitle     = fieldToDB($eArray[2]);	$eDesc      = $eArray[3];	$eDateStart = extDateToMySQL($eArray[4]);
	$eDateEnd   = extDateToMySQL($eArray[5]);
	$eOnHome    = $eArray[6];
	$eLocation  = fieldToDB($eArray[7]);	$eTimes     = fieldToDB($eArray[8]);
	$eURL       = $eArray[9];		if ($eURL == 'http://') {		$eURL = '';	}	if ($eRegURL == 'http://') {		$eRegURL = '';	}			if ($action == 'add') {			$sql = "INSERT into transEvents (				ECat,				Userid,				EventTitle,				EventLocation,				EventDesc,				EventURL,				DateStart,				DateEnd,				EventTimes,				Active,
				OnHome				) values (				'$eCat',				'$userid',				'$eTitle',				'$eLocation',				'$eDesc',				'$eURL',				'$eDateStart',				'$eDateEnd',				'$eTimes',				'1',
				'$eOnHome'				)";	} elseif ($action == 'edit') {		$sql = "UPDATE transEvents SET				ECat          = '$eCat',				EventTitle    = '$eTitle',				EventLocation = '$eLocation',				EventDesc     = '$eDesc',				EventURL      = '$eURL',				DateStart     = '$eDateStart',				DateEnd       = '$eDateEnd',				EventTimes    = '$eTimes',
				Active        = '1',
				OnHome        = '$eOnHome'				WHERE EID = '$eID'";	}				$result = mysql_db_query($dbname,$sql);}
function deleteEvent($eID) {	global $dbname, $db, $db_selected, $pre;		$sql = "DELETE from transEvents WHERE EID = '$eID'";	$result = mysql_db_query($dbname,$sql);}function getEventForEdit($eID) {	global $editString, $dbname, $db, $db_selected, $pre;		$sql = "SELECT * from transEvents WHERE EID = '$eID'";	$result = mysql_db_query($dbname,$sql);	$row = mysql_fetch_assoc($result);		$eCat       = $row[ECat];	$eTitle     = stripslashes($row[EventTitle]);	$eLocation  = DBToField($row[EventLocation]);	$eDesc      = stripslashes($row[EventDesc]);	$eURL       = $row[EventURL];	$eTimes     = $row[EventTimes];
	$eActive    = $row[Active];
	$eOnHome    = $row[OnHome];		// Extract date from datetime	$eDateStartArray = explode(' ',$row[DateStart]);	$eDateEndArray   = explode(' ',$row[DateEnd]);		$eDateStart = mySQLToExt($eDateStartArray[0]);	$eDateEnd   = mySQLToExt($eDateEndArray[0]);			$editString = $eID.'|'.$eCat.'|'.$eTitle.'|'.$eLocation.'|'.$eDesc.'|'.$eURL.'|'.$eDateStart.'|'.$eDateEnd.'|'.$eTimes.'|'.$eActive.'|'.$eOnHome;	return $editString;}
function swapOnHome($eID) {	global $returnString, $dbname, $db, $db_selected, $pre;		$sql = "SELECT OnHome from transEvents WHERE EID = '$eID'";	$result = mysql_db_query($dbname,$sql);	$row = mysql_fetch_assoc($result);	$onHome = $row[OnHome];		if ($onHome == 1) {		$newOnHome = 0;		$returnString = '<img src="images/iconCheckGreenOff.gif" onClick="swapOnHome('.$eID.'); return false;" style="cursor: pointer;" alt="Click to display on home page" /> <span style="color: #ccc;">On Home Page</span>';		} else {		$newOnHome = 1;		$returnString = '<img src="images/iconCheckGreenOn.gif" onClick="swapOnHome('.$eID.'); return false;" style="cursor: pointer;" alt="Click to remove from home page" /> On Home Page';		}	
	// Reset all other records to NOT be on home page
	/*
	 * Let's not do this for now
	 */
	/*	 
	$sqlUpdate1 = "UPDATE transEvents SET OnHome = 0";
	$result1 = mysql_db_query($dbname,$sqlUpdate1);
	*/	$sqlUpdate = "UPDATE transEvents SET OnHome = '$newOnHome' WHERE EID = '$eID'";	$result = mysql_db_query($dbname,$sqlUpdate);		return $eID.'|'.$returnString;}function swapActive($eID) {	global $returnString, $dbname, $db, $db_selected, $pre;		$sql = "SELECT Active from transEvents WHERE EID = '$eID'";	$result = mysql_db_query($dbname,$sql);	$row = mysql_fetch_assoc($result);	$active = $row[Active];		if ($active == 1) {		$newActive = 0;		$returnString = '<img src="images/iconCheckGreenOff.gif" onClick="swapActive('.$eID.'); return false;" style="cursor: pointer;" alt="Click to activate event" /> <span style="color: #ccc;">Not Active</span>';		} else {		$newActive = 1;		$returnString = '<img src="images/iconCheckGreenOn.gif" onClick="swapActive('.$eID.'); return false;" style="cursor: pointer;" alt="Click to deactivate event" /> Active Event';		}		$sqlUpdate = "UPDATE transEvents SET Active = '$newActive' WHERE EID = '$eID'";	$result = mysql_db_query($dbname,$sqlUpdate);		return $eID.'|'.$returnString;}?>